package com.store.app.activity;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.InputFilter;
import android.text.Spanned;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;

import com.store.app.BaseActivity;
import com.store.app.ExitApplication;
import com.store.app.MainActivity;
import com.store.app.R;
import com.store.app.bean.GoodsListBean;
import com.store.app.imlife.utils.ToastTools;
import com.store.app.net.NetRequest;
import com.store.app.net.ifc.IOnHttpListener;
import com.store.app.utils.DateUtil;
import com.store.app.utils.DeductionUtils;
import com.store.app.utils.IDUtil;
import com.store.app.utils.MoneyUtil;
import com.store.app.utils.SettingData;
import com.store.app.utils.ToastUtils;
import com.store.app.utils.Utils;

import org.json.JSONObject;

import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2016/8/23.
 * 结算页面
 */
public class SumNewActivity extends BaseActivity implements IOnHttpListener, View.OnClickListener {

    private ImageView retreat;                      //返回
    private TextView handle;                        //应付价格
    private LinearLayout manner_cash;               //现金支付
    private LinearLayout manner_family_card;        //亲情卡支付
    private LinearLayout manner_pay_code;           //收款码支付
    private LinearLayout manner_alipay;             //支付宝支付
    private LinearLayout manner_wechat;             //微信支付
    private LinearLayout manner_yi_pay;             //翼支付
    private LinearLayout manner_package_pay;        //和包支付
    private String price_original = "0";            //应付金额
    private String discount_price = "0";            //折扣金额
    private String needPay = "0";                  //应付－折扣 = 应收
    private String rewardData = "0";                //收银记录送金币  ，需要判断是否满足资格
    private String rebateData  = "0";               //收银记录返现
    private String dikouData = "0";                 //收银时候抵扣的值
    public static final int WECHAT_PAY = 1, YI_PAY = 11, HZF_PAY = 3, ALIPAY = 4, FAMILYPAY = 5, CASH_PAY = 6,PHONE_PAY = 7,MOBILE_PACKAGE_PAY = 8;
    public static final int XIAOPIAO=20;
    private NetRequest netRequest;
    private int width;
    private int height;
    private TextView tv_send_code;
    private EditText et_member_phone;
    private TextView vip_favorable_text1;       //折扣减掉的钱
    private TextView vip_favorable_text2;       //返现的钱
    private TextView vip_favorable_text3;       //送币
    private EditText et_dikou;                  //抵扣
    private String pay_type;                    //支付方式
    private String change="0.00";               //零钱找零
    private String s_outtradeno="";             //交易单号
    private String s_outtradeno_date="";             //交易时间
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        setContentView(R.layout.activity_sum);
        ExitApplication.getInstance().addActivity(this);
        initView();
        initData();
    }

    @Override
    public void onAfinalFail() {
        dismissProgressDialog();
        ToastTools.showShort(SumNewActivity.this,"请检查本地网络");
    }

    @Override
    public void onExecuteSuccess(int requestId, String result, String msg) {
        dismissProgressDialog();
        if (requestId == 1) {
            //结算成功弹窗
            try {
               // showSuccPop(retreat);
                List<GoodsListBean> goodsListBeanList=CashierActivity.goodsListBeanList;
                if(goodsListBeanList==null||goodsListBeanList.size()==0){
                    Toast.makeText(SumNewActivity.this,"获取小票失败！",Toast.LENGTH_SHORT).show();
                }else {
                    Intent intent = new Intent(SumNewActivity.this, XiaopiaoDialogActivity.class);
                    intent.putExtra("price_original", MoneyUtil.formatMoney(price_original));
                    intent.putExtra("discount_price", discount_price);
                    intent.putExtra("needPay", needPay);
                    intent.putExtra("pay_type", pay_type);
                    intent.putExtra("change", change);
                    intent.putExtra("outtradeno_date",s_outtradeno_date);
                    intent.putExtra("outtradeno",s_outtradeno);
                    String s_dikou=et_dikou.getText().toString().trim();
                    if(!TextUtils.isEmpty(s_dikou)){
                        intent.putExtra("dikou",s_dikou);
                    }else{
                        intent.putExtra("dikou","0.00");
                    }
                    intent.putExtra("songbi",rewardData);
                    intent.putExtra("fangxian",rebateData);
                    startActivityForResult(intent,XIAOPIAO);
                }
            } catch (Exception e) {
                finish();
            }
        } else if (requestId == 2) {
            //判断下是否会员，如果是，跳转到验证码结算页面结算页面
            try {
                JSONObject jsonObject = new JSONObject(result);
                String consumer_id = jsonObject.getString("consumer_id");
                String mobile = jsonObject.getString("mobile");
                String nick_name = jsonObject.getString("nick_name");
                Intent intent = new Intent(SumNewActivity.this, CodePaymentActivity.class);
                intent.putExtra("price_original", Double.parseDouble(price_original));
                intent.putExtra("phone", mobile);
                intent.putExtra("consumer_id", consumer_id);
                intent.putExtra("nick_name", nick_name);
                if(!TextUtils.isEmpty(et_dikou.getText().toString().trim())){
                    dikouData = et_dikou.getText().toString().trim();
                    String money = MoneyUtil.moneySub(needPay, et_dikou.getText().toString().trim());
                    intent.putExtra("money", money);
                }else{
                    dikouData = "0";
                    intent.putExtra("money", needPay);//实际支付数量
                }
                intent.putExtra("price_original",price_original);
                intent.putExtra("discount_price",discount_price);
                intent.putExtra("dikouData",dikouData);
                intent.putExtra("rebateData",rebateData);
                intent.putExtra("rewardData",rewardData);
                startActivityForResult(intent, PHONE_PAY);
            } catch (Exception e) {

            }
        }
    }


    @Override
    public void onExecuteFail(int requestId, String msg) {
        dismissProgressDialog();
        if(requestId ==3){

        }else{
            ToastUtils.showTextToast(SumNewActivity.this, msg);
        }

    }


    private void initView() {
        retreat = (ImageView) findViewById(R.id.retreat);
        handle = (TextView) findViewById(R.id.handle);
        manner_cash = (LinearLayout) findViewById(R.id.manner_cash);
        manner_family_card = (LinearLayout) findViewById(R.id.manner_family_card);
        manner_pay_code = (LinearLayout) findViewById(R.id.manner_pay_code);
        manner_alipay = (LinearLayout) findViewById(R.id.manner_alipay);
        manner_wechat = (LinearLayout) findViewById(R.id.manner_wechat);
        manner_yi_pay = (LinearLayout) findViewById(R.id.manner_yi_pay);
        manner_package_pay = (LinearLayout) findViewById(R.id.manner_package_pay);
        retreat.setOnClickListener(this);
        manner_cash.setOnClickListener(this);
        manner_family_card.setOnClickListener(this);
        manner_pay_code.setOnClickListener(this);
        manner_alipay.setOnClickListener(this);
        manner_wechat.setOnClickListener(this);
        manner_yi_pay.setOnClickListener(this);
        manner_package_pay.setOnClickListener(this);

        tv_send_code = (TextView) findViewById(R.id.tv_send_code);
        tv_send_code.setOnClickListener(this);
        et_member_phone = (EditText) findViewById(R.id.et_member_phone);
        vip_favorable_text1 = (TextView) findViewById(R.id.vip_favorable_text1);
        vip_favorable_text2 = (TextView) findViewById(R.id.vip_favorable_text2);
        vip_favorable_text3 = (TextView) findViewById(R.id.vip_favorable_text3);


        et_dikou = (EditText) findViewById(R.id.et_dikou);
        et_dikou.setFilters(new InputFilter[]{new InputMoney()});
    }

    private void initData() {
        Intent intent = getIntent();
        price_original = intent.getStringExtra("price_original");
        Log.v("zyl", "接收到的price_original：" + price_original);
        handle.setText(price_original);//原始金额
        netRequest = new NetRequest(this);
        WindowManager wm = this.getWindowManager();
        width = wm.getDefaultDisplay().getWidth();
        height = wm.getDefaultDisplay().getHeight();
        //原价-折扣需付的价格,支付时候需要判断是否有抵扣的情况
        needPay = DeductionUtils.plan(price_original);
        //折扣的金额
        discount_price = MoneyUtil.moneySub(price_original, needPay);

        refreshUI();
    }

    private void refreshUI() {
        if (SettingData.discountStatus.equals("enable")) {
            vip_favorable_text1.setText("减免 ¥ " + discount_price);
        } else {
            vip_favorable_text1.setText("减免 ¥ 0.00");
        }

        if (SettingData.rebateStatus.equals("enable")) {
            //满足返现资格才显示
            if(MoneyUtil.moneyComp(price_original,SettingData.moreRebate)){
                vip_favorable_text2.setText("返现 ¥ " + MoneyUtil.formatMoney(SettingData.moreRebateData));
                rebateData = SettingData.moreRebateData;
            }
            else{
                vip_favorable_text2.setText("返现 ¥ 0.00");
            }
        } else {
            vip_favorable_text2.setText("返现 ¥ 0.00");
        }

        if (SettingData.rewardStatus.equals("enable")) {
            if(MoneyUtil.moneyComp(price_original,SettingData.moreReward)){
                vip_favorable_text3.setText("送币 "+SettingData.moreRewardData);
                rewardData = SettingData.moreRewardData;
            }else{
                vip_favorable_text3.setText("送币 0 ");
            }
        } else {
            vip_favorable_text3.setText("送币 0 ");
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.retreat:
                finish();
                break;
            //现金收款
            case R.id.manner_cash:

                if(!checkMoneyWithNodis()){
                    return;
                }
                Intent intent = new Intent();
                intent.setClass(SumNewActivity.this, PayByCashActivity.class);
                //这里的price_original其实是应付价格，旧代码暂时不改。
                //抵扣不为空时候，应付价格需要减去抵扣价格
                if(!TextUtils.isEmpty(et_dikou.getText().toString().trim())){
                    dikouData = et_dikou.getText().toString().trim();
                    String money = MoneyUtil.moneySub(price_original, et_dikou.getText().toString().trim());
                    intent.putExtra("price_original", Double.parseDouble(money));
                }else{
                    dikouData = "0";
                    intent.putExtra("price_original", Double.parseDouble(price_original));//实际支付数量
                }
                startActivityForResult(intent, CASH_PAY);
                break;
            //亲情卡
            case R.id.manner_family_card:
                if(!checkMoneyWithDis()){
                    return;
                }
                Intent intentFamily = new Intent();
                if(!TextUtils.isEmpty(et_dikou.getText().toString().trim())){
                    dikouData = et_dikou.getText().toString().trim();
                    String money = MoneyUtil.moneySub(needPay, et_dikou.getText().toString().trim());
                    intentFamily.putExtra("money", money);
                }else{
                    dikouData = "0";
                    intentFamily.putExtra("money", needPay);//实际支付数量
                }

                intentFamily.putExtra("price_original",price_original);
                intentFamily.putExtra("discount_price",discount_price);
                intentFamily.putExtra("dikouData",dikouData);
                intentFamily.putExtra("rebateData",rebateData);
                intentFamily.putExtra("rewardData",rewardData);
                intentFamily.setClass(SumNewActivity.this, FamilyCardPayCaptureActivity.class);
                startActivityForResult(intentFamily, FAMILYPAY);
                break;
            //收款码
            case R.id.manner_pay_code:
                if(!checkMoneyWithDis()){
                    return;
                }
                Intent intent6 = new Intent();
                if(!TextUtils.isEmpty(et_dikou.getText().toString().trim())){
                    dikouData = et_dikou.getText().toString().trim();
                    String money = MoneyUtil.moneySub(needPay, et_dikou.getText().toString().trim());
                    intent6.putExtra("money", money);
                }else{
                    dikouData = "0";
                    intent6.putExtra("money", needPay);//实际支付数量
                }
                intent6.setClass(SumNewActivity.this, PayCaptureActivity.class);
                intent6.putExtra("price_original",price_original);
                intent6.putExtra("discount_price",discount_price);
                intent6.putExtra("dikouData",dikouData);
                intent6.putExtra("rebateData",rebateData);
                intent6.putExtra("rewardData", rewardData);
                startActivityForResult(intent6, HZF_PAY);
                break;
            //支付宝
            case R.id.manner_alipay:
                if(!checkMoneyWithNodis()){
                    return;
                }
                Intent intentAlipay = new Intent();
                if(!TextUtils.isEmpty(et_dikou.getText().toString().trim())){
                    dikouData = et_dikou.getText().toString().trim();
                    String money = MoneyUtil.moneySub(price_original, et_dikou.getText().toString().trim());
                    intentAlipay.putExtra("money", money);
                }else{
                    dikouData = "0";
                    intentAlipay.putExtra("money", price_original);//实际支付数量
                }
                intentAlipay.setClass(SumNewActivity.this, AlipayCaptureActivity.class);
                startActivityForResult(intentAlipay, ALIPAY);
                break;
            //微信
            case R.id.manner_wechat:
                if(!checkMoneyWithNodis()){
                    return;
                }
                Intent intentWX = new Intent();
                if(!TextUtils.isEmpty(et_dikou.getText().toString().trim())){
                    dikouData = et_dikou.getText().toString().trim();
                    String money = MoneyUtil.moneySub(price_original, et_dikou.getText().toString().trim());
                    intentWX.putExtra("money", money);
                }else{
                    dikouData = "0";
                    intentWX.putExtra("money", price_original);//实际支付数量
                }
                intentWX.setClass(SumNewActivity.this, WeChatCaptureActivity.class);
                startActivityForResult(intentWX, WECHAT_PAY);
                break;
            //翼支付
            case R.id.manner_yi_pay:
                if(!checkMoneyWithNodis()){
                    return;
                }
                Intent intentYi = new Intent();
                if(!TextUtils.isEmpty(et_dikou.getText().toString().trim())){
                    dikouData = et_dikou.getText().toString().trim();
                    String money = MoneyUtil.moneySub(price_original, et_dikou.getText().toString().trim());
                    intentYi.putExtra("money", money);
                }else{
                    dikouData = "0";
                    intentYi.putExtra("money", price_original);//实际支付数量
                }
                intentYi.setClass(SumNewActivity.this, YiPayCaptureActivity.class);
                startActivityForResult(intentYi, YI_PAY);
                break;
            //和包支付
            case R.id.manner_package_pay:
                if(!checkMoneyWithNodis()){
                    return;
                }
                Intent intentPackage = new Intent();
                if(!TextUtils.isEmpty(et_dikou.getText().toString().trim())){
                    dikouData = et_dikou.getText().toString().trim();
                    String money = MoneyUtil.moneySub(price_original, et_dikou.getText().toString().trim());
                    intentPackage.putExtra("money", money);
                }else{
                    dikouData = "0";
                    intentPackage.putExtra("money", price_original);//实际支付数量
                }
                intentPackage.setClass(SumNewActivity.this, MobilePacketPayCaptureActivity.class);
                startActivityForResult(intentPackage, MOBILE_PACKAGE_PAY);

                break;
            //获取验证码
            case R.id.tv_send_code:
                String phone = et_member_phone.getText().toString().trim();
                Log.v("zyl", "获取验证码：" + phone);
                if(Utils.isFastClick()){
                    return;
                }
                if(!checkMoneyWithDis()){
                    Log.v("zyl","获取验证码价格是否通过“"+!checkMoneyWithDis());
                    return;
                }
                if (TextUtils.isEmpty(phone)) {
                    Toast.makeText(SumNewActivity.this, "请输入会员的手机号！", Toast.LENGTH_SHORT).show();
                    return;
                }
                if (!Utils.matchPhone(phone)) {
                    Toast.makeText(SumNewActivity.this, "请输入正确的手机号！", Toast.LENGTH_SHORT).show();
                } else {
                    //判断是否会员
                    netRequest.requestVailsMemberExist(2, phone);
                }
                break;
        }
    }
    //有优惠的金额检查
    public boolean checkMoneyWithDis(){
        String dikou = et_dikou.getText().toString().trim();
        if(!TextUtils.isEmpty(dikou)){
            String tempneedPay = MoneyUtil.moneySub(needPay,dikou);//减去抵扣后得到真正支付的价格
            Log.v("zyl","tempneedPay:"+tempneedPay);
            if(!MoneyUtil.moneyBigThan(tempneedPay,"0")){
                ToastTools.showShort(SumNewActivity.this,"实收金额应大于0");
                return false;
            }else{
                Log.v("zyl", "应付价格：" + needPay);
                return true;
            }
        }else {
            Log.v("zyl", "应付价格：" + needPay);
            return true;
        }
    }

    /**
     * 没有优惠的金额检查
     * @return
     */
    public boolean checkMoneyWithNodis(){
        String dikou = et_dikou.getText().toString().trim();
        if(!TextUtils.isEmpty(dikou)){
            String tempneedPay = MoneyUtil.moneySub(price_original,dikou);//减去抵扣后得到真正支付的价格
            Log.v("zyl","tempneedPay:"+tempneedPay);
            if(!MoneyUtil.moneyBigThan(tempneedPay,"0")){
                ToastTools.showShort(SumNewActivity.this,"实收金额应大于0");
                return false;
            }else{
                Log.v("zyl","应付价格："+price_original);
                return true;
            }
        }else {
            Log.v("zyl","应付价格："+price_original);
            return true;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        s_outtradeno_date= DateUtil.date2Str(new Date(), "yyyy-MM-dd HH:mm:ss");             //交易时间
        s_outtradeno = "";
        //现金收款其实只做了收银记录
        if (requestCode == CASH_PAY) {
            if (resultCode == Activity.RESULT_OK) {
                s_outtradeno= IDUtil.getOutTradeNo();
                Log.v("zyl", "discount_price:" + discount_price);
                showProgressDialog("","正在生成小票...");
                netRequest.requestCommitRecord(1, "0", "0", s_outtradeno, price_original, dikouData,"0", MoneyUtil.moneySub(price_original,dikouData),SettingData.PAYMENT_WAY_04);
                pay_type=SettingData.PAYMENT_WAY_04;
                String s_change=data.getStringExtra("change");
                if(TextUtils.isEmpty(s_change)){
                    change="0.00";
                }else{
                    change=s_change;
                }
            }
        }
        //微信
        else if (requestCode == WECHAT_PAY) {
            if (resultCode == Activity.RESULT_OK) {
                s_outtradeno =  data.getStringExtra("out_trade_no");
                Log.v("zyl", "data.getStringExtra:" + data.getStringExtra("resultMoney"));
                showProgressDialog("", "正在生成小票...");
                netRequest.requestCommitRecord(1, "0", "0", s_outtradeno, price_original, dikouData, "0",data.getStringExtra("resultMoney"), SettingData.PAYMENT_WAY_11);
                pay_type=SettingData.PAYMENT_WAY_11;
                netRequest.requestStoreCashierPromotion(3, s_outtradeno,SettingData.meitianhui_buyer_id, MainActivity.member_id,"微信",SettingData.PAYMENT_WAY_11,price_original,discount_price,dikouData,rebateData,rewardData,data.getStringExtra("resultMoney"),data.getStringExtra("transaction_no"),"","");
            }
        }
        //翼支付
        else if (requestCode == YI_PAY) {
            if (resultCode == Activity.RESULT_OK) {
                s_outtradeno =  data.getStringExtra("out_trade_no");
                showProgressDialog("","正在生成小票...");
                netRequest.requestCommitRecord(1, "0", "0", s_outtradeno, price_original, dikouData, "0",data.getStringExtra("resultMoney"), SettingData.PAYMENT_WAY_14);
                pay_type=SettingData.PAYMENT_WAY_14;
                netRequest.requestStoreCashierPromotion(3, s_outtradeno,SettingData.meitianhui_buyer_id, MainActivity.member_id,"翼支付",SettingData.PAYMENT_WAY_14,price_original,discount_price,dikouData,rebateData,rewardData,data.getStringExtra("resultMoney"),data.getStringExtra("transaction_no"),"","");

            }
        }
        //和包支付
        else if (requestCode == MOBILE_PACKAGE_PAY) {
            if (resultCode == Activity.RESULT_OK) {
                s_outtradeno =  data.getStringExtra("out_trade_no");
                showProgressDialog("","正在生成小票...");
                netRequest.requestCommitRecord(1, "0", "0", s_outtradeno, price_original, dikouData, "0",data.getStringExtra("resultMoney"), SettingData.PAYMENT_WAY_25);
                pay_type=SettingData.PAYMENT_WAY_25;
                netRequest.requestStoreCashierPromotion(3, s_outtradeno,SettingData.meitianhui_buyer_id, MainActivity.member_id,"和包支付",SettingData.PAYMENT_WAY_25,price_original,discount_price,dikouData,rebateData,rewardData,data.getStringExtra("resultMoney"),data.getStringExtra("transaction_no"),"","");

            }
        }

        //扫码支付 （本地生活出示交易号）
        else if (requestCode == HZF_PAY) {
            if (resultCode == Activity.RESULT_OK) {
                s_outtradeno =  data.getStringExtra("out_trade_no");
                Log.v("zyl","获取到的s_outtradeno："+s_outtradeno);
                showProgressDialog("","正在生成小票...");
                netRequest.requestCommitRecord(1, rebateData, rewardData, s_outtradeno, price_original, dikouData,discount_price, data.getStringExtra("resultMoney"), SettingData.PAYMENT_WAY_05);
                pay_type=SettingData.PAYMENT_WAY_05+"H";
//                netRequest.requestStoreCashierPromotion(3,
//                        data.getStringExtra("flow_no"),
//                        data.getStringExtra("buyer_id"),
//                        MainActivity.member_id
//                        ,"付款码",SettingData.PAYMENT_WAY_05,price_original,discount_price,dikouData,rebateData,rewardData,data.getStringExtra("resultMoney"),data.getStringExtra("transaction_no"),data.getStringExtra("flow_no"));

            }
        }
        //支付宝
        else if (requestCode == ALIPAY) {
            if (resultCode == Activity.RESULT_OK) {
                s_outtradeno =  data.getStringExtra("out_trade_no");
                showProgressDialog("","正在生成小票...");
                netRequest.requestCommitRecord(1, "0", "0",s_outtradeno, price_original, dikouData, "0",data.getStringExtra("resultMoney"), SettingData.PAYMENT_WAY_10);
                pay_type=SettingData.PAYMENT_WAY_10;
                netRequest.requestStoreCashierPromotion(3, s_outtradeno,SettingData.meitianhui_buyer_id, MainActivity.member_id,"支付宝",SettingData.PAYMENT_WAY_10,price_original,discount_price,dikouData,rebateData,rewardData,data.getStringExtra("resultMoney"),data.getStringExtra("transaction_no"),"","");
            }
        }
        //亲情卡
        else if (requestCode == FAMILYPAY) {
            if (resultCode == Activity.RESULT_OK) {
                s_outtradeno =  data.getStringExtra("out_trade_no");
                showProgressDialog("","正在生成小票...");
                netRequest.requestCommitRecord(1, rebateData, rewardData, s_outtradeno, price_original, dikouData, discount_price, data.getStringExtra("resultMoney"), SettingData.PAYMENT_WAY_05);
                pay_type=SettingData.PAYMENT_WAY_05;
//                netRequest.requestStoreCashierPromotion(3,s_outtradeno,
//                        data.getStringExtra("buyer_id"),
//                        MainActivity.member_id,
//                        data.getStringExtra("card_no"),
//                        "亲情卡",SettingData.PAYMENT_WAY_05,
//                        price_original,
//                        discount_price,
//                        dikouData,
//                        rebateData
//                        ,rewardData,data.getStringExtra("resultMoney"),data.getStringExtra("transaction_no"),"");

            }
        }
        else if(requestCode == PHONE_PAY) {
            if (resultCode == Activity.RESULT_OK) {
                s_outtradeno =  data.getStringExtra("out_trade_no");
                showProgressDialog("","正在生成小票...");
                netRequest.requestCommitRecord(1,rebateData, rewardData,s_outtradeno, price_original, dikouData, discount_price,data.getStringExtra("resultMoney"), SettingData.PAYMENT_WAY_05);
                pay_type=SettingData.PAYMENT_WAY_05+"Y";

//                netRequest.requestStoreCashierPromotion(3,s_outtradeno,
//                        data.getStringExtra("buyer_id"),
//                        MainActivity.member_id,
//                        data.getStringExtra("card_no"),
//                        "验证码支付",SettingData.PAYMENT_WAY_05,
//                        price_original,
//                        discount_price,
//                        dikouData,
//                        rebateData
//                        ,rewardData,data.getStringExtra("resultMoney"),data.getStringExtra("transaction_no"),"");

            }
        }


        //小票
        else if (requestCode == XIAOPIAO) {
            if (resultCode == Activity.RESULT_OK) {
               SumNewActivity.this.finish();
            }
        }
    }


    /**
     * 结算成功
     *
     * @param view
     */
    public void showSuccPop(View view) {
        // 一个自定义的布局，作为显示的内容
        final View contentView = LayoutInflater.from(this).inflate(
                R.layout.cash_register_finish, null);
        // 设置按钮的点击事件
        ImageView occlude = (ImageView) contentView.findViewById(R.id.occlude);
        occlude.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                CashierActivity.goodsListBeanList.clear();
                CashierActivity.handler.sendEmptyMessage(1);
                finish();
            }
        });
        PopupWindow popupWindow = new PopupWindow(contentView, width - 100, ActionBar.LayoutParams.WRAP_CONTENT);
        popupWindow.setAnimationStyle(R.style.popwin_anim_style);
        popupWindow.setTouchable(true);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        popupWindow.showAtLocation(view, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
    }
    public class InputMoney implements InputFilter{

        @Override
        public CharSequence filter(CharSequence source, int start, int end,
                                   Spanned dest, int dstart, int dend) {
            // TODO Auto-generated method stub
            if (source.toString().equals(".") && dstart == 0 && dend == 0) {//判断小数点是否在第一位
                et_dikou.setText(0+""+source+dest);//给小数点前面加0
                et_dikou.setSelection(2);//设置光标
            }

            if (dest.toString().indexOf(".") != -1 && (dest.length() - dest.toString().indexOf(".")) > 2) {//判断小数点是否存在并且小数点后面是否已有两个字符
                if ((dest.length() - dstart) < 3) {//判断现在输入的字符是不是在小数点后面
                    return "";//过滤当前输入的字符
                }
            }

            return null;
        }

    }
}
